<?php
	/* 
	 * 主题分类
	 */
	 switch($ts){
		case "":
	 		$zhuticate = $db->fetch_all_assoc("select * from ".dbprefix."theme_cate order by cateid");
	 		include template("admin/zhuticate");
		break;
		case "do":
			$arrcateid = $_POST['cateid'];
			$arrname = $_POST['name'];
			
			foreach($arrname as $key=>$item){
			$cateid = trim($arrcateid[$key]);
			$name = trim($item);
			if($name){
				$iscateid = $db ->once_num_rows("select cateid from ".dbprefix."theme_cate where cateid='".$cateid."'");
				if($iscateid){
				$updatenav = $db->query("UPDATE ".dbprefix."theme_cate SET  name='".$name."' where cateid = '".$cateid."'");
				}else{
				$insertnav = $db->query("insert into ".dbprefix."theme_cate SET  name='".$name."'");
				}
				
				
				
			}else{
				
				qiMsg("主题分类名称不能为空！","<a href=\"index.php?app=share&ac=admin&mg=zhuticate\">返回</a>");
				
			}
			
			
		}
			
			$arrtheme_cate = $db->fetch_all_assoc("select * from ".dbprefix."theme_cate");
			fileWrite('theme_cate.php','data',$arrtheme_cate);
			
			qiMsg("主题分类修改成功！","<a href=\"index.php?app=share&ac=admin&mg=zhuticate\">返回</a>");
		break;
		
		case "del":
			$cateid = $_GET['cateid'];
			$isdel = $db->query("DELETE FROM ".dbprefix."theme_cate WHERE cateid=".$cateid);
			$arrtheme_cate = $db->fetch_all_assoc("select * from ".dbprefix."theme_cate");
			fileWrite('theme_cate.php','data',$arrtheme_cate);
			qiMsg("主题分类删除成功！");
		break;
	}