<!--#include file="base.asp"-->
<%
''' EYCMS 栏目
''' ==================================================================

	sub loadsondb()
		dim str:str=""
		dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
		dim data:data=eycms.db.dbload("","cateid,followid,ordnum,catename,modeid,modelname,ismenu,allowpost,sonid,islocked,cateurl,model_allowpost,cate_show","view_category","followid="&classid&"","ordnum,cateid")
		if ubound(data)<0 then
			exit sub
		end if
		dim i,url,isdim
		for i=0 to ubound(data,2)
			url=eycms.iiif(data(4,i)=-1,data(4,i)=-2,"page","link","")
			isdim=eycms.iif(len(data(12,i))=0,"yes",(data(12,i)))
			if isdim="model/page/eycms_page.asp" then isdim="yes"
			str=str&"<tr id="""&data(0,i)&""" pId="""&data(1,i)&""""
			if instr(data(8,i),",")>0 then
				str=str&" hasChild=""true"""
			end if
			str=str&">"
			str=str&"	<td class=""txt_left""><a href=""../list.asp?classid="&data(0,i)&""" target=""_blank"">"&data(3,i)&"</a></td>"
			str=str&"	<td>"&data(0,i)&"<input type=""hidden"" name=""cid"" value="""&data(0,i)&""" ></td>"
			str=str&"	<td><input type=""text"" name=""ordnum"" id="""&data(0,i)&""" value="""&data(2,i)&""" size=""4"" maxlength=""4"" class=""ordnum"" data-rule=""排序:required;digit""></td>"
			str=str&"	<td>"&eycms.iiif(data(4,i)=-1,data(4,i)=-2,"<em>单网页</em>","<u>外部链接</u>","内部栏目")&"</td>"
			str=str&"	<td>"&data(5,i)&"</td>"
			str=str&"	<td>"&eycms.iif(data(6,i)=1,"是","<span>否</span>")
			If user_lock=1 Then str=str&" / "&eycms.iif(data(11,i)=1, eycms.iif(data(7,i)=1,"是","<span>否</span>"), "<span>否</span>")
			str=str&"</td>"
			str=str&"	<td><a href=""?act=add"&url&"&id="&data(0,i)&"&moid="&data(4,i)&"""><img src='../theme/admin_leo/images/add.png' width='16' height='16' title='添加子分类' align='absmiddle'/></a>&nbsp;&nbsp;"
			if data(4,i)=-1 Then
				if eycms.strlen(data(10,i))>0 then
					str=str&"<img src='../theme/admin_leo/images/blank.gif' width='16' height='16'align='absmiddle'/>"
				else
					if isdim="yes" then 
						str=str&"<a href=""ey_model_page.asp?classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>"
					else
						str=str&"<a href=""ey_model_page.asp?act=html&classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>"
					end if
				end If
			elseif data(4,i)=-2 then
				str=str&"<img src='../theme/admin_leo/images/blank.gif' width='16' height='16'align='absmiddle'/>"
			else
				str=str&"<a href=""ey_content.asp?classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>"
			end If
			
			str=str&"&nbsp;&nbsp;<a href=""?act=move&id="&data(0,i)&"""><img src='../theme/admin_leo/images/move.png' width='16' height='16' title='移动' align='absmiddle'/></a>&nbsp;&nbsp;<a href=""?act=edit"&url&"&id="&data(0,i)&"""><img src='../theme/admin_leo/images/edit.png' width='16' height='16' title='编辑' align='absmiddle'/></a>&nbsp;&nbsp;"

			str=str&eycms.iif(data(9,i)=1,"<a href=""javascript:;""><img src='../theme/admin_leo/images/lock.png' width='16' height='16' title='被锁定' align='absmiddle'/></a>","<a href=""javascript:;"" class=""del"" rel="""&data(0,i)&"""><img src='../theme/admin_leo/images/delete.png' width='16' height='16' title='删除' align='absmiddle'/></a>")

			If data(4,i)=5 Then 
				str=str&"&nbsp;&nbsp;<a href='javascript:;' onclick=""openset("&data(0,i)&")""><img src='../theme/admin_leo/images/set.png' width='16' height='16' title='设置' align='absmiddle'/></a>"
			Else
				str=str&"&nbsp;&nbsp;<img src='../theme/admin_leo/images/blank.gif' width='16' height='16'align='absmiddle'/>"
			End if

			str=str&"</td></tr>"
		next
		eycms.echo str
	end sub
	
	sub classlist(byval t0)
		dim i, j, cont, child
		dim isdim
		j=1
		for i=0 to ubound(data,2)
			if t0=data(3,i) Then
				If getcatestatus(data(0,i)) then
					isdim=eycms.iif(len(data(21,i))=0,"yes",data(21,i))
					if isdim="model/page/eycms_page.asp" then isdim="yes"
					child=""
					class_list=class_list&"<tr id=""class_"&data(0,i)&""">"


					If InStr(data(5,i),",")>0 Then
						child="　　<a href='?cateid="&data(0,i)&"' title='展开子栏目'><img src='../theme/admin_leo/images/arr.gif' border=0 width=40 height=10 align=absmiddle></a>"
					End If

					class_list=class_list&"	<td class=""txt_left"">"&eycms.iif(data(3,i)>0,cont,"")&data(1,i)&child&"</td>"
					class_list=class_list&"	<td>"&data(0,i)&"<input type=""hidden"" name=""cid"" value="""&data(0,i)&""" ></td>"

					class_list=class_list&"	<td><input type=""text"" name=""ordnum"" id="""&data(0,i)&""" value="""&data(7,i)&""" size=""4"" maxlength=""4"" class=""ordnum"" data-rule=""排序:required;digit""></td>"

					class_list=class_list&"	<td>"&eycms.iiif(data(10,i)=-1,data(10,i)=-2,"<em>单网页</em>","<u>外部链接</u>","内部栏目")&"</td>"
					class_list=class_list&"	<td>"&data(11,i)&"</td>"
					class_list=class_list&"	<td>"&eycms.iif(data(8,i)=1,"是","<span>否</span>")
					If user_lock=1 Then class_list=class_list&" / "&eycms.iif(data(33,i)=1, eycms.iif(data(31,i)=1,"是","<span>否</span>"), "<span>否</span>")
					class_list=class_list&"</td>"
					class_list=class_list&"	<td><a href=""?act=add"&eycms.iiif(data(10,i)=-1,data(10,i)=-2,"page","link","")&"&id="&data(0,i)&"&moid="&data(10,i)&"""><img src='../theme/admin_leo/images/add.png' width='16' height='16' title='添加子分类' align='absmiddle'/></a>&nbsp;&nbsp;"
					select case data(10,i)
						case "-1"
							if eycms.strlen(data(9,i))>0 then
								class_list=class_list&"<a href=""?cateid="&data(0,i)&"&catemode=1""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='展开子栏目' align='absmiddle'/></a>&nbsp;&nbsp;"
							Else
								if isdim="yes" then 
									class_list=class_list&"<a href=""ey_model_page.asp?classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>&nbsp;&nbsp;"
								else
									class_list=class_list&"<a href=""ey_model_page.asp?act=html&classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>&nbsp;&nbsp;"
								end if
							End If
						case "-2"
							class_list=class_list&"<img src='../theme/admin_leo/images/blank.gif' width='16' height='16'align='absmiddle'/>&nbsp;&nbsp;"
						case else
							class_list=class_list&"<a href="" ey_content.asp?classid="&data(0,i)&"""><img src='../theme/admin_leo/images/view.png' width='16' height='16' title='内容管理' align='absmiddle'/></a>&nbsp;&nbsp;"
					end select

					class_list=class_list&"<a href=""?act=move&id="&data(0,i)&"""><img src='../theme/admin_leo/images/move.png' width='16' height='16' title='移动' align='absmiddle'/></a>&nbsp;&nbsp;<a href=""?act=edit"&eycms.iiif(data(10,i)=-1,data(10,i)=-2,"page","link","")&"&id="&data(0,i)&"""><img src='../theme/admin_leo/images/edit.png' width='16' height='16' title='编辑' align='absmiddle'/></a> &nbsp;"&eycms.iif(data(34,i)=1,"<a href=""javascript:;""><img src='../theme/admin_leo/images/lock.png' width='16' height='16' title='被锁定' align='absmiddle'/></a>","<a href=""javascript:;"" class=""del"" rel="""&data(0,i)&"""><img src='../theme/admin_leo/images/delete.png' width='16' height='16' title='删除' align='absmiddle'/></a>")
					If data(10,i)=5 Then 
						class_list=class_list&"&nbsp;&nbsp;<a href='javascript:;' onclick=""openset("&data(0,i)&")""><img src='../theme/admin_leo/images/set.png' width='16' height='16' title='设置' align='absmiddle'/></a>"
					Else
						class_list=class_list&"<img src='../theme/admin_leo/images/blank.gif' width='16' height='16'align='absmiddle'/>&nbsp;&nbsp;"
					End if
					class_list=class_list&"</td></tr>"&vbcrlf
				End if
			end if
		next
	end sub
	
	sub orderdb()
		dim t0,t1,t2,t3,i
		t0=eycms.enhtml(eycms.fpost("ordnum",0))
		t1=eycms.enhtml(eycms.fpost("cid",0))
		t2=split(t0,", ")
		t3=split(t1,", ")
		if ubound(t2)-ubound(t3)<>0 then eycms.ajaxjson "0&#21442;&#25968;&#38169;&#35823;",0:exit sub
		for i=0 to ubound(t2)
			if eycms.isnum(t2(i)) then
				eycms.db.dbupdate "ey_category","cateid="&t3(i)&"",array(array("ordnum",t2(i),10,0,0))
			end if
		next
		eycms.ajaxjson "保存成功",1
	end sub
	
	sub adddb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,cutsize
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.getint(eycms.fpost("t4",0),0)
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.getint(eycms.fpost("t6",0),20)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		t10=eycms.enhtml(eycms.fpost("t10",0))
		t11=eycms.enhtml(eycms.fpost("t11",0))
		t12=eycms.enhtml(eycms.fpost("t12",0))
		t13=eycms.enhtml(eycms.fpost("t13",0))
		t14=eycms.getint(eycms.fpost("t14",0),0)
		t15=eycms.getint(eycms.fpost("t15",0),0)
		t16=eycms.getint(eycms.fpost("t16",0),0)
		t17=eycms.getint(eycms.fpost("t17",0),200)
		t18=eycms.getint(eycms.fpost("t18",0),200)
		cutsize=t17&"*"&t18

		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		add_class_one array(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,cutsize)
		eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
	end sub
	
	sub addmoredb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.getint(eycms.fpost("t4",0),0)
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.getint(eycms.fpost("t6",0),20)
		t7=eycms.getint(eycms.fpost("t7",0),0)
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		t10=eycms.enhtml(eycms.fpost("t10",0))
		t11=eycms.enhtml(eycms.fpost("t11",0))
		t12=eycms.enhtml(eycms.fpost("t12",0))
		t13=eycms.enhtml(eycms.fpost("t13",0))
		t14=eycms.getint(eycms.fpost("t14",0),0)
	
		if eycms.strlen(t0)=0 then eycms.ajaxjson  "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim i,cname,result
		t0=replace(t0,chr(13),"")
		t1=split(t0,chr(10))
		for i=0 to ubound(t1)
			dim c_0,c_1
			if instr(t1(i),"|")>0 then
				cname=split(t1(i),"|")
				c_0=trim(cname(0))
				c_1=trim(cname(1))
			else
				c_0=trim(t1(i))
				c_1=""
			end if
			if eycms.strlen(c_0)>0 then
				add_class_one array(c_0,c_1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,0,0,"")
			end if
		next
		eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
	end sub
	
	sub add_class_one(byval str)
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17
		if not isarray(str) then exit sub
		t0=str(0)
		t1=str(1)
		t2=str(2)
		t3=str(3)
		t4=str(4)
		t5=str(5)
		t6=str(6)
		t7=str(7)
		t8=str(8)
		t9=str(9)
		t10=str(10)
		t11=str(11)
		t12=str(12)
		t13=str(13)
		t14=str(14)
		t15=str(15)
		t16=str(16)
		t17=str(17)
		if eycms.strlen(t1)=0 then t1=eycms.get_pinyin(t0)
		if t1="/" or right(lcase(t1),1)="/" or left(lcase(t1),1)="/" or not(eycms.checkstr(t1,"file")) then
			eycms.ajaxjson ""&t1&"&#33521;&#25991;&#30446;&#24405;&#22635;&#20889;&#38169;&#35823;",0:eycms.die
		end if
		if t1="brand" or t1="goods" or t1="plug" or t1="user" or t1="html" then t1 = t1 & "s"
		dim thisid
		dim depth
		data=eycms.db.dbload(1,"depth","ey_category","cateid="&t2&"","")
		if ubound(data)<0 then
			depth=1
		else
			depth=data(0,0)+1
		end if
		data=array(array("catename",t0,50),array("catedir",t1,255),array("followid",t2,10),array("modeid",t3,10),array("ismenu",t4,1),array("catepic",t5,255),array("pagenum",t6,10),array("ordnum",t7,10),array("cate_list",t8,255),array("cate_show",t9,255),array("seotitle",t10,255),array("catekey",t11,255),array("catedesc",t12,0),array("urlrule",t13,0),array("depth",depth,0),array("allowpost",t14,1),array("islocked",t15,1,0),array("iscut",t16,1,0),array("cutsize",t17,50,1))
		
		if eycms.db.dbnew("ey_category",data,"catename='"&t0&"' and followid="&t2&"")=0 then
			eycms.ajaxjson ""&t0&"&#26639;&#30446;&#21517;&#31216;&#24050;&#23384;&#22312;&#65292;&#35831;&#25442;&#20010;&#35797;&#35797;&#65281;",0:eycms.die
		else
			thisid=eycms.db.insertid("cateid","ey_category")
			updatecatelever thisid,"add"
			data=array(array("sonid",thisid,0,1),array("parentid","["&thisid&"]",0,1))
			eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
			if t2>0 then
				dim datanew,pareid
				datanew=eycms.db.dbload(1,"parentid","ey_category","cateid="&t2&"","")
				pareid=datanew(0,0)
				data=array(array("parentid",pareid&"["&thisid&"]",0,1))
				eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
				pareid=Replace(pareid,"][",",")
				pareid=Replace(pareid,"[","")
				pareid=Replace(pareid,"]","")
				datanew=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&pareid&")","")
				dim i,newid,newson
				for i=0 to ubound(datanew,2)
					newid=datanew(0,i)
					newson=datanew(1,i)
					data=array(array("sonid",newson&","&thisid,0,1))
					eycms.db.dbupdate "ey_category","cateid="&newid&"",data
				next
			end if
			deal_file thisid,3
		end if
	end sub
	
	sub addlinkdb()
		dim t0,t1,t2,t3,t4,t5,t6,thisid
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		t6=eycms.enhtml(eycms.fpost("t6",0))
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t4)=0 then eycms.ajaxjson "&#38142;&#25509;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0:exit Sub
		if eycms.strlen(t6)=0 then t6=eycms.get_pinyin(t0)
		if t6="/" or right(lcase(t6),1)="/" or left(lcase(t6),1)="/" or not(eycms.checkstr(t6,"file")) then
			eycms.ajaxjson ""&t6&"&#33521;&#25991;&#30446;&#24405;&#22635;&#20889;&#38169;&#35823;",0:exit sub
		end if
		dim depth
		data=eycms.db.dbload(1,"depth","ey_category","cateid="&t1&"","")
		if ubound(data)<0 then
			depth=1
		else
			depth=data(0,0)+1
		end if
		data=array(array("catename",t0,50),array("catedir",t6,255),array("followid",t1,10),array("modeid",-2,2),array("ismenu",t2,1),array("catepic",t3,255),array("pagenum",0,1),array("cateurl",t4,255),array("ordnum",t5,10),array("depth",depth,0),array("allowpost",0,0))
		
		if eycms.db.dbnew("ey_category",data,"catename='"&t0&"' and followid="&t1&"")=0 then
			eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#24050;&#23384;&#22312;&#65292;&#35831;&#25442;&#20010;&#35797;&#35797;&#65281;",0:exit sub
		else
			thisid=eycms.db.insertid("cateid","ey_category")
			updatecatelever thisid,"add"
			data=array(array("sonid",thisid,0,1),array("parentid","["&thisid&"]",0,1))
			eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
			if t1>0 then
				dim datanew,pareid
				datanew=eycms.db.dbload(1,"parentid","ey_category","cateid="&t1&"","")
				pareid=datanew(0,0)
				data=array(array("parentid",pareid&"["&thisid&"]",0,1))
				eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
				pareid=Replace(pareid,"][",",")
				pareid=Replace(pareid,"[","")
				pareid=Replace(pareid,"]","")
				datanew=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&pareid&")","")
				dim i,newid,newson
				for i=0 to ubound(datanew,2)
					newid=datanew(0,i)
					newson=datanew(1,i)
					data=array(array("sonid",newson&","&thisid,0,1))
					eycms.db.dbupdate "ey_category","cateid="&newid&"",data
				next
			end if
			deal_file thisid,3
			eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
		end if
	end sub
	
	sub addpagedb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		t10=eycms.enhtml(eycms.fpost("t10",0))
		t11=eycms.getint(eycms.fpost("t11",0),0)

		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		add_page_one array(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)
		eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
	end sub
	
	sub addpagemoredb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim i,cname,result
		t0 = replace(t0,chr(13),"")
		t0 = Replace(t0, CHR(10), "#")
		t0 = Replace(t0, vbcrlf, "#")
		t0 = Replace(t0, "##", "#")
		t0 = Replace(t0, "##", "#")
		t1 = split(t0,"#")
		for i=0 to ubound(t1)
			dim c_0,c_1
			if instr(t1(i),"|")>0 then
				cname=split(t1(i),"|")
				c_0=trim(cname(0))
				c_1=trim(cname(1))
			else
				c_0=trim(t1(i))
				c_1=""
			end if
			if eycms.strlen(c_0)>0 then
				add_page_one array(c_0,c_1,t2,t3,t4,"",t5,t6,t7,t8,t9,0)
			end if
		next
		eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
	end sub
	
	sub add_page_one(byval str)
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,thisid
		t0=str(0)
		t1=str(1)
		t2=str(2)
		t3=str(3)
		t4=str(4)
		t5=str(5)
		t6=str(6)
		t7=str(7)
		t8=str(8)
		t9=str(9)
		t10=str(10)
		t11=str(11)

		if eycms.strlen(t1)=0 then t1=eycms.get_pinyin(t0)
		if t1="/" or right(lcase(t1),1)="/" or left(lcase(t1),1)="/" or not(eycms.checkstr(t1,"file")) then
			eycms.ajaxjson ""&t1&"&#33521;&#25991;&#30446;&#24405;&#22635;&#20889;&#38169;&#35823;",0:eycms.die
		end if

		dim depth
		data=eycms.db.dbload(1,"depth","ey_category","cateid="&t2&"","")
		if ubound(data)<0 then
			depth=1
		else
			depth=data(0,0)+1
		end if

		data=array(array("catename",t0,50),array("catedir",t1,255),array("followid",t2,10),array("modeid",-1,2),array("ismenu",t3,1),array("catepic",t4,255),array("pagenum",0,1),array("cateurl",t5,255,1),array("ordnum",t6,10),array("depth",depth,0),array("cate_show",t7,255),array("seotitle",t8,255),array("catekey",t9,255),array("catedesc",t10,0),array("allowpost",0,0),array("islocked",t11,1,0))

		if eycms.db.dbnew("ey_category",data,"catename='"&t0&"' and followid="&t2&"")=0 then
			eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#24050;&#23384;&#22312;&#65292;&#35831;&#25442;&#20010;&#35797;&#35797;&#65281;",0:eycms.die
		else
			thisid=eycms.db.insertid("cateid","ey_category")
			updatecatelever thisid,"add"
			data=array(array("sonid",thisid,0,1),array("parentid","["&thisid&"]",0,1))
			eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
			if t2>0 then
				dim datanew,pareid
				datanew=eycms.db.dbload(1,"parentid","ey_category","cateid="&t2&"","")
				pareid=datanew(0,0)
				data=array(array("parentid",pareid&"["&thisid&"]",0,1))
				eycms.db.dbupdate "ey_category","cateid="&thisid&"",data
				pareid=Replace(pareid,"][",",")
				pareid=Replace(pareid,"[","")
				pareid=Replace(pareid,"]","")
				datanew=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&pareid&")","")
				dim i,newid,newson
				for i=0 to ubound(datanew,2)
					newid=datanew(0,i)
					newson=datanew(1,i)
					data=array(array("sonid",newson&","&thisid,0,1))
					eycms.db.dbupdate "ey_category","cateid="&newid&"",data
				next
			end if
			deal_file thisid,3
		end if
	end sub
	
	sub editdb()
		dim t0,t1,t2,t2_1,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,cutsize
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t2_1=eycms.getint(eycms.fpost("t2_1",0),0)
		t3=eycms.getint(eycms.fpost("t3",0),0)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),20)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		t10=eycms.enhtml(eycms.fpost("t10",0))
		t11=eycms.enhtml(eycms.fpost("t11",0))
		t12=eycms.enhtml(eycms.fpost("t12",0))
		t13=eycms.getint(eycms.fpost("t13",0),0)
		t14=eycms.getint(eycms.fpost("t14",0),0)
		t15=eycms.getint(eycms.fpost("t15",0),0)
		t16=eycms.getint(eycms.fpost("t16",0),200)
		t17=eycms.getint(eycms.fpost("t17",0),200)
		t18=eycms.getint(eycms.fpost("t18",0),0)
		t19=eycms.getint(eycms.fpost("t19",0),0)
		cutsize=t16&"*"&t17
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t1)=0 then t1=eycms.get_pinyin(t0)
		if t1="/" or right(lcase(t1),1)="/" or left(lcase(t1),1)="/" or  not(eycms.checkstr(t1,"file")) then
			eycms.ajaxjson "&#33521;&#25991;&#30446;&#24405;&#22635;&#20889;&#38169;&#35823;",0:exit sub
		end If
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		if t2_1<>0 then
			t2=eycms.db.dbloadone("modeid","ey_category","cateid="&id&"")
		end if
		
		data=array(array("catename",t0,50,1),array("catedir",t1,255,1),array("modeid",t2,0,0),array("ismenu",t3,1,0),array("catepic",t4,255,1),array("pagenum",t5,12,0),array("ordnum",t6,12,0),array("cate_list",t7,255,1),array("cate_show",t8,255,1),array("seotitle",t9,255,1),array("catekey",t10,255,1),array("catedesc",t11,0,1),array("urlrule",t12,0,1),array("allowpost",t13,1,0),array("islocked",t14,1,0),array("iscut",t15,1,0),array("cutsize",cutsize,50,1))
		if eycms.db.dbupdate("ey_category","cateid="&id&"",data)=1 then
			if t18>0 or t19>0 then
				dim fstr,i
				fstr="array("
				if t18>0 then fstr = fstr & "array(""cate_list"",t7,255,1),array(""cate_show"",t8,255,1),"
				if t19>0 then fstr = fstr & "array(""pagenum"",t5,12,0)"
				if right(fstr,1)="," then fstr=left(fstr,len(fstr)-1)
				fstr=fstr & ")"
				data=eycms.db.dbload("","cateid,modeid","ey_category","cateid in("& eycms.get_sonid(id) &")","")
				if ubound(data)>=0 then
					for i=0 to ubound(data,2)
						if data(1,i)=t2 then eycms.db.dbupdate "ey_category", "cateid="&data(0,i)&"", eval(fstr)
					next
				end if
			end if
			eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
		end if
	end sub
	
	sub editlinkdb()
		dim t0,t1,t2,t3,t4,t5
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.getint(eycms.fpost("t1",0),0)
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.getint(eycms.fpost("t4",0),0)
		t5=eycms.enhtml(eycms.fpost("t5",0))
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("catename",t0,50,1),array("catedir",t5,255,1),array("ismenu",t1,3,0),array("catepic",t2,255,1),array("cateurl",t3,255,1),array("ordnum",t4,10,0))
		if eycms.db.dbupdate("ey_category","cateid="&id&"",data)=1 then
			eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
		end if
	end sub
	
	sub editpagedb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.enhtml(eycms.fpost("t9",0))
		t10=eycms.getint(eycms.fpost("t10",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t1)=0 then t1=eycms.get_pinyin(t0)
		if t1="/" or right(lcase(t1),1)="/" or left(lcase(t1),1)="/" or  not(eycms.checkstr(t1,"file")) then
			eycms.ajaxjson "&#33521;&#25991;&#30446;&#24405;&#22635;&#20889;&#38169;&#35823;",0:exit sub
		end if
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("catename",t0,50,1),array("catedir",lcase(t1),255,1),array("ismenu",t2,3,0),array("catepic",t3,255,1),array("cateurl",t4,255,1),array("ordnum",t5,12,0),array("cate_show",t6,0,1),array("seotitle",t7,255,1),array("catekey",t8,255,1),array("catedesc",t9,0,1),array("islocked",t10,1,0))
		if eycms.db.dbupdate("ey_category","cateid="&id&"",data)=1 then
			eycms.ajaxjson "&#20445;&#23384;&#25104;&#21151;",1
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		data=eycms.db.dbload(1,"followid,sonid,parentid,modeid,(select tablename from ey_model where ey_model.modelid=ey_category.modeid),catepic","ey_category","cateid="&id&"","")
		
		if ubound(data)>=0 then
			if instr(data(1,0),",")>0 then
				eycms.echo "0&#19981;&#33021;&#21024;&#38500;&#65292;&#35831;&#20808;&#21024;&#38500;&#23376;&#26639;&#30446;&#65281;":exit sub
			else
				select case data(3,0)
					case -1
						eycms.db.dbdel "ey_model_page","classid="&id&""
						deal_del_file id,2
						delclassurl id
					case -2:
					case else
						delclassurl id
						dim tablename,dbs,j
						tablename=data(4,0)
						dbs=eycms.db.dbload("","id","ey_content","classid="&id&"","")
						if ubound(dbs)>=0 then
							for j=0 to ubound(dbs,2)
								eycms.db.dbdel tablename,"cid="&dbs(0,j)&""
								eycms.db.dbdel "ey_expand_mood","contentid="&dbs(0,j)&""
								eycms.db.dbdel "ey_expand_comment","contentid="&dbs(0,j)&""
								If user_lock=1 Then eycms.db.dbdel "ey_user_favorite","contentid="&dbs(0,j)&""
								deal_del_file dbs(0,j),1
							next
						end if
						eycms.db.dbdel "ey_content","classid="&id&""
				end select
				dim datanew,pareid,i,newsonid
				pareid=Replace(data(2,0),"][",",")
				pareid=Replace(pareid,"[","")
				pareid=Replace(pareid,"]","")
				datanew=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&pareid&")","")
				for i=0 to ubound(datanew,2)
					newsonid=replace(","&datanew(1,i)&",", ","&id&",", ",")
					if right(newsonid,1)="," then newsonid=left(newsonid,len(newsonid)-1)
					if left(newsonid,1)="," then newsonid=right(newsonid,len(newsonid)-1)
					eycms.db.dbupdate "ey_category","cateid="&datanew(0,i)&"",array(array("sonid",newsonid,0,1))
				next
				deal_del_file id,3
				eycms.db.dbdel "ey_category","cateid="&id&""
				updatecatelever id,"del"
			end if
		end if

		eycms.echo "1删除成功"
	end sub
	
	sub movedb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		dim t0:t0=eycms.getint(eycms.fpost("t0",0),0)
		data=eycms.db.dbload(1,"followid,sonid,parentid","ey_category","cateid="&id&"","")
		if ubound(data)<0 then eycms.ajaxjson "&#21442;&#25968;&#38169;&#35823;",0:exit sub
		dim old_followid,old_allclassid,old_partentid,old_pid
		old_followid=data(0,0)
		old_allclassid=data(1,0)
		old_partentid=data(2,0)

		old_pid=Replace(old_partentid,"][",",")
		old_pid=Replace(old_pid,"[","")
		old_pid=Replace(old_pid,"]","")
		dim old_followid_num
		old_followid_num=eycms.db.dbcount("ey_category","followid="&id&"")
		if clng(t0)=clng(old_followid) then eycms.ajaxjson "&#27809;&#26377;&#31227;&#21160;",0:exit sub
		dim old_allclassid01
		old_allclassid01=replace(","&old_allclassid&",",""&id&"","")
		if instr(","&old_allclassid01&",",","&t0&",")>0 then eycms.ajaxjson"&#19981;&#33021;&#31227;&#21160;&#21040;&#23376;&#26639;&#30446;&#19979;",0:exit sub
		if clng(t0)=clng(id) then eycms.ajaxjson "&#19981;&#33021;&#31227;&#21160;&#33258;&#24049;&#19979;&#38754;",0
		if t0=0 Then   '作为一级栏目
			dim o_partentid,n_partentid
			dim o_allclassid,n_allclassid
			if old_followid_num=0 then
				data=eycms.db.dbload("","cateid,parentid","ey_category","cateid in("&old_allclassid&")","cateid desc")
				dim i,j
				if ubound(data)>=0 then
					for i=0 to ubound(data,2)
						dim datanew
						datanew=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&old_pid&") and cateid<>"&data(0,i)&"","cateid")
						for j=0 to ubound(datanew,2)
							n_allclassid=replace(","&datanew(1,j)&",",","&data(0,i)&",",",")
							if left(n_allclassid,1)="," then n_allclassid=right(n_allclassid,eycms.strlen(n_allclassid)-1)
							if right(n_allclassid,1)="," then n_allclassid=left(n_allclassid,eycms.strlen(n_allclassid)-1)
							eycms.db.dbupdate "ey_category","cateid="&datanew(0,j)&"",array(array("sonid",n_allclassid,0,1))
						next
						n_partentid=replace("["&data(0,i)&"]"&data(1,i), old_partentid, "")
						eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("parentid",n_partentid,0,1))
					next
				end if
				eycms.db.dbupdate "ey_category","cateid="&id&"",array(array("followid",0,0,0))
				redepth
				eycms.ajaxjson "栏目移动成功",1
			else
				data=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&old_pid&") and cateid<>"&id&"","cateid desc")
				for i=0 to ubound(data,2)
					n_allclassid=replace(","&data(1,i)&",",","&old_allclassid&",",",")
					if left(n_allclassid,1)="," then n_allclassid=right(n_allclassid,eycms.strlen(n_allclassid)-1)
					if right(n_allclassid,1)="," then n_allclassid=left(n_allclassid,eycms.strlen(n_allclassid)-1)
					eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("sonid",n_allclassid,0,1))
				next

				dim old_old_old_partentid
				old_old_old_partentid=replace(old_partentid,"["&id&"]","")
				data=eycms.db.dbload("","cateid,parentid","ey_category","cateid in("&Old_allclassid&")","cateid desc")
				for i=0 to ubound(data,2)
					n_partentid=replace(data(1,i),old_old_old_partentid,"")
					eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("parentid",n_partentid,0,1))
				next
				eycms.db.dbupdate "ey_category","cateid="&id&"",array(array("followid",0,0,0))
				redepth
				eycms.ajaxjson "栏目移动成功",1
			end if
		else
			dim pare_followid,datafoll,pare_sonid,pare_pid,pare_pstr
			datafoll=eycms.db.dbload(1,"followid,sonid,parentid","ey_category","cateid="&t0&"","")
			pare_followid=datafoll(0,0)
			pare_sonid=datafoll(1,0)
			pare_pid=datafoll(2,0)
			pare_pstr=Replace(pare_pid,"][",",")
			pare_pstr=Replace(pare_pstr,"[","")
			pare_pstr=Replace(pare_pstr,"]","")

			if old_followid<>pare_followid then
				dim new_allclassid,new_partentid,new_pstr
				data=eycms.db.dbload(1,"sonid,parentid","ey_category","cateid="&t0&"","")
				if ubound(data)<0 then
					eycms.ajaxjson "&#26469;&#28304;&#38169;&#35823;",0:exit sub
				else
					new_allclassid=data(0,0)
					new_partentid=data(1,0)
					new_pstr=Replace(new_partentid,"][",",")
					new_pstr=Replace(new_pstr,"[","")
					new_pstr=Replace(new_pstr,"]","")
				end if
				if old_followid=0 then
					data=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&new_pstr&")","")
					if ubound(data)>=0 then
						for i=0 to ubound(data,2)
							eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("sonid",data(1,i)&","&old_allclassid,0,1))
						next
					end if
					if old_followid_num=0 then
						eycms.db.dbupdate "ey_category","cateid="&id&"",array(array("parentid",new_partentid&"["&id&"]",0,1))
					else
						dim o_o_o_o_partentid,n_n_n_n_partentid
						data=eycms.db.dbload("","cateid,parentid","ey_category","cateid in("&Old_allclassid&")","")
						if ubound(data)>=0 then
							for i=0 to ubound(data,2)
								o_o_o_o_partentid=data(1,i)
								n_n_n_n_partentid=replace(o_o_o_o_partentid,"["&old_followid&"]","")
								eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("parentid",new_partentid&n_n_n_n_partentid,0,1))
							next
						end if
					end if
				else
					dim o_o_o_partentid,o_o_partentid,n_n_partentid,o_o_o_pstr
					o_o_o_partentid=replace(old_partentid,"["&id&"]","")
					o_o_o_pstr=Replace(o_o_o_partentid,"][",",")
					o_o_o_pstr=Replace(o_o_o_pstr,"[","")
					o_o_o_pstr=Replace(o_o_o_pstr,"]","")
					data=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&o_o_o_pstr&")","")
					if ubound(data)>=0 then
						for i=0 to ubound(data,2)
							n_n_partentid=replace(","&data(1,i)&",",","&old_allclassid&",",",")
							if left(n_n_partentid,1)="," then n_n_partentid=right(n_n_partentid,eycms.strlen(n_n_partentid)-1)
							if right(n_n_partentid,1)="," then n_n_partentid=left(n_n_partentid,eycms.strlen(n_n_partentid)-1)
							eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("sonid",n_n_partentid,0,1))
						next
					end if
					data=eycms.db.dbload("","cateid,sonid","ey_category","cateid in("&new_pstr&")","")
					if ubound(data)>=0 then
						for i=0 to ubound(data,2)
							eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("sonid",data(1,i)&","&old_allclassid,0,1))
						next
					end if
					
					if old_followid_num=0 Then
						eycms.db.dbupdate "ey_category","cateid="&id&"",array(array("parentid",new_partentid&"["&id&"]",0,1))
					else
						dim old_old_partentid
						old_old_partentid=replace(old_partentid,"["&id&"]","")
						
						dim o_o_o_o_o_partentid,n_n_n_n_n_partentid
						data=eycms.db.dbload("","cateid,parentid","ey_category","cateid in("&old_allclassid&")","")
						if ubound(data)>=0 then
							for i=0 to ubound(data,2)
								o_o_o_o_o_partentid=data(1,i)
								n_n_n_n_n_partentid=replace(o_o_o_o_o_partentid,old_old_partentid,"")
								eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("parentid",new_partentid&n_n_n_n_n_partentid,0,1))
							next
						end if
					end if
				end if
			else
				data=eycms.db.dbload("","cateid,parentid","ey_category","cateid in("&old_allclassid&")","")
				if ubound(data)>=0 then
					for i=0 to ubound(data,2)
						o_o_o_o_o_partentid=data(1,i)
						o_o_o_o_o_partentid=replace(o_o_o_o_o_partentid,"["&old_followid&"]","")
						o_o_o_o_o_partentid=pare_pid & o_o_o_o_o_partentid
						eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("parentid",o_o_o_o_o_partentid,0,1))
					next
				end if
				
				eycms.db.dbupdate "ey_category","cateid="&t0&"",array(array("sonid",pare_sonid&","&old_allclassid,0,1))
			end if
			eycms.db.dbupdate "ey_category","cateid="&id&"",array(array("followid",t0,0,0))
			redepth
			eycms.ajaxjson "栏目移动成功",1
		end if
	end sub
	
	sub reset()
		data=eycms.db.dbload("","cateid,followid,depth,sonid,parentid","ey_category","","")
		if ubound(data)>=0 then
			dim i,thisid
			for i=0 to ubound(data,2)
			thisid=data(0,i)
			eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("followid",0,0,0),array("depth",1,0,0),array("sonid",thisid,0,1),array("parentid","["&thisid&"]",0,1))
			next
		end if
		eycms.echo "1栏目复位成功"
	end sub
	
	dim get_sonid:get_sonid=""
	sub getsonid(byval t0)
		dim rs
		get_sonid=get_sonid&","&t0
		set rs=eycms.db.conn.execute("select cateid,followid from ey_category where followid="&t0&"")
		if rs.eof then
			exit sub
		end if
		while not rs.eof
			if instr(get_sonid&",",","&rs(0)&",")<0 then
				get_sonid=get_sonid&","&rs(0)
			end if
			getsonid rs(0)
		rs.movenext
		wend
		rs.close
		set rs=nothing
	end sub
	
	dim get_parid:get_parid=""
	sub getparid(byval t0)
		dim rs
		get_parid="[" & t0 & "]" & get_parid
		set rs=eycms.db.conn.execute("select followid from ey_category where cateid="&t0&"")
		if rs.eof then
			exit sub
		else
			if rs(0)=0 then
				exit sub
			else		
				getparid rs(0)
			end if
		end if
	end sub
	
	function get_sid(byval t0)
		getsonid(t0)
		get_sid=repair_id(get_sonid)
		get_sonid=""
	end function
	
	function get_pid(byval t0)
		getparid(t0)
		get_pid=get_parid
		get_parid=""
	end function
	
	function repair_id(byval t0)
		if len(t0)<=0 then
			repair_id=t0
		else
			repair_id=right(t0,len(t0)-1)
		end if
	end function
	
	sub repair()
		dim rs,t0,t1,t2
		set rs=server.createobject("adodb.recordset")
		rs.open "select cateid from ey_category",eycms.db.conn,1,3
		while not rs.eof
			t0=get_sid(rs(0))
			t1=get_pid(rs(0))
			t2=ubound(split(t1,","))+1
			eycms.db.conn.execute("update ey_category set sonid='"&t0&"',parentid='"&t1&"',depth="&t2&" where cateid="&rs(0)&"")
		rs.movenext
		wend
		rs.close
		set rs=nothing
		eycms.echo "1修复成功"
	end sub
	
	sub gettemp()
		dim modid,listname
		modid=eycms.getint(eycms.fget("modid",0),0)
		listname=eycms.fget("listname",0)
		if modid=0 then
			eycms.echo "":exit sub
		end if
		data=eycms.db.dbload(1,"default_temp,list_temp,show_temp","ey_model","modelid="&modid&"","")
		if ubound(data)<0 then
			eycms.echo ""
		else
			eycms.echo "<select onchange=""$('#"&listname&"').val(this.value)""><option>列表模板选择</option><option value="""&data(0,0)&""">频道模板("&data(0,0)&")</option>><option value="""&data(1,0)&""">列表模板("&data(1,0)&")</option></select>"
		end if
	end sub
	
	sub loadtemp()
		dim t0:t0=eycms.enhtml(eycms.fget("t0",1))
		dim t1:t1=eycms.enhtml(eycms.fget("t1",1))
		if eycms.strlen(t1)=0 or t1="undefined" then t1="pro"
		dim fso,fsofolder,fsocontent,fsocount,folder,str
		folder=theme_root&"/model/"&t1&""
		str="<ul class=""templist"">"
		str=str&"<li class=""tips""><span>提示：</span>模板选择请谨慎操作</li>"
		set fso=createobject("scripting.filesystemobject")
		If tempencry=False then
			set fsofolder=fso.getfolder(server.mappath(""&webroot&"theme/"&folder))
		Else
			set fsofolder=fso.getfolder(server.mappath(""&webroot&"encry/theme/"&folder))
		End if
        set fsocontent=fsofolder.files

        dim fsoitem
        for each fsoitem in fsocontent
			if lcase(fsoitem.name)<>"config.asp" and lcase(fsoitem.name)<>"base.asp" and lcase(fsoitem.name)<>"config.xml" then
				str=str&"<li><span>"&getblockname("model/"&t1&"/"&fsoitem.name)&"</span><a href=""javascript:;"" onClick=""getid('"&t0&"','model/"&t1&"/"&fsoitem.name&"')"">"&fsoitem.name&"</a></li>"
			end if
		next
        set fso=nothing
        set fsofolder=nothing
        set fsocontent=nothing
		str=str&"</ul>"
		eycms.echo str
	end sub
	
	sub redepth()
		dim depth
		data=eycms.db.dbload("","cateid,parentid","ey_category","","")
		dim i
		if ubound(data)>=0 then
			for i=0 to ubound(data,2)
				depth=ubound(split(data(1,i),"]["))+1
				eycms.db.dbupdate "ey_category","cateid="&data(0,i)&"",array(array("depth",depth,0,0))
			next
		end if
	end sub
	
	sub recache()
		dim gonum:gonum=eycms.getint(eycms.fget("go",0),0)
		eycms.delcache "category"
		if gonum=1 then eycms.echo "1栏目缓存更新成功"
	end sub
	
	sub delclassurl(byval t0)
		if webmode=3 then
			dim classurl:classurl=eycms.getcateurl(t0)
			eycms.delfolder classurl
		end if
	end sub
	
	sub pinyin()
		dim t0:t0=eycms.enhtml(eycms.fpost("t0",0))
		if eycms.strlen(t0)=0 then eycms.echo "0&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;":exit sub
		eycms.echo eycms.get_pinyin(t0)
	end sub
	
	sub english()
		dim t0:t0=eycms.enhtml(eycms.fpost("t0",0))
		if eycms.strlen(t0)=0 then eycms.echo "0&#26639;&#30446;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;":exit sub
		eycms.echo eycms.get_english(t0)
	end sub

	sub catemode()
		dim t0:t0=eycms.getsys("catemode")
		t0=1-CInt(t0)
		eycms.db.dbupdate "ey_config","setname='eycms.site' and setkey='catemode'",array(array("setvalue",t0,0,1))
		eycms.delcache "eycmsdata"
		eycms.echo "1栏目显示模式已切换"
	end Sub

	sub updatecatelever(byval id, byval lx)
		if admingroupid=0 then exit sub
		if id>0 Then
			dim t0:t0 = admin_cate_array
			dim data
			Select Case lx
			Case "add"
				if instr(","&t0&",",","&id&",")<=0 then
					t0 = t0 & "," & id
					admin_cate_array = t0
					data=array(array("catearray",t0,0,1))
					eycms.db.dbupdate "ey_admin_group","id="&admingroupid&"",data
				End If
			Case "del"
				if instr(","&t0&",",","&id&",")>0 then
					t0 = Replace(","&t0&",", ","&id&",", ",")
					If Left(t0,1)="," Then t0=Right(t0,Len(t0)-1)
					If Right(t0,1)="," Then t0=Left(t0,Len(t0)-1)
					admin_cate_array = t0
					data=array(array("catearray",t0,0,1))
					eycms.db.dbupdate "ey_admin_group","id="&admingroupid&"",data
				end If
			End select
		end if
	end Sub

	Function getAttrField(cid)
		If cid>0 Then
			dim data,i,str01,str02,str03,used
			data=eycms.db.dbload("","fname","ey_attr_set",eycms.getWhere(cid),"")
			if ubound(data)>=0 then
				for i=0 to ubound(data,2)
					used=used&"["&data(0,i)&"]"
				Next
			End If
			data=eycms.db.dbload("","fname","ey_attr_set","classid in("&eycms.get_sonid(cid)&")","")
			if ubound(data)>=0 then
				for i=0 to ubound(data,2)
					used=used&"["&data(0,i)&"]"
				Next
			End if
			str01="<select name=""t0"" id=""t0"" class=""ip""><option value="""" selected>选择字段</option>"
			str03="</select>"
			for i=1 To 5
				If InStr(used,"[attr"&i&"]")<=0 then
					str02=str02&"<option value=""attr"&i&""""&">attr"&i&"</option>"
				End if
			Next
			getAttrField = str01&str02&str03
		End if
	End Function

	sub attradddb()
		classid=eycms.getint(eycms.fget("classid",0),0)
		dim t0,t1,t2,t3,t4,t5,t6
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "字段名称不能为空",0:exit sub
		if eycms.strlen(t1)=0 then eycms.ajaxjson "字段别名不能为空",0:exit sub
		if eycms.strlen(t2)=0 then eycms.ajaxjson "字段类型不能为空",0:exit sub
		t0=left(t0,20)
		dim data
		data=array(array("fname",t0,0),array("falias",t1,9),array("fclass",t2,0),array("fmode",1,0),array("fdatatype",1,0),array("flength",255,5),array("fdefault",t3,255),array("foptions",t4,0),array("fismust",1,0),array("frules",1,0),array("fistrim",0,0),array("ordnum",t5,0),array("islock",t6,0),array("fupload",0,0),array("classid",classid,0))
		if eycms.db.dbnew("ey_attr_set",data,"fname='"&t0&"' and classid="&classid&"")=0 then
			eycms.ajaxjson "属性名称已存在，请换个试试",0:exit sub
		else
			eycms.ajaxjson "保存成功",1
		end if
	end Sub
	
	sub attreditdb()
		dim t1,t2,t3,t4,t5,t6
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.getint(eycms.fpost("t2",0),0)
		t3=eycms.enhtml(eycms.fpost("t3",0))
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		t6=eycms.getint(eycms.fpost("t6",0),0)
		if eycms.strlen(t1)=0 then eycms.ajaxjson "字段别名不能为空",0:exit sub
		if eycms.strlen(t2)=0 then eycms.ajaxjson "字段类型不能为空",0:exit sub
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		data=array(array("falias",t1,9,1),array("fclass",t2,0,0),array("fdefault",t3,255,1),array("foptions",t4,0,1),array("ordnum",t5,0,0),array("islock",t6,0,0))
		if eycms.db.dbupdate("ey_attr_set","id="&id&"",data)=1 then
			eycms.ajaxjson "保存成功",1
		end if
	end Sub
	
	sub attrorderdb()
		dim t0,t1,t2,t3,i
		t0=eycms.enhtml(eycms.fpost("ordnum",0))
		t1=eycms.enhtml(eycms.fpost("id",0))
		t2=split(t0,", ")
		t3=split(t1,", ")
		if ubound(t2)-ubound(t3)<>0 then eycms.ajaxjson "0&#21442;&#25968;&#38169;&#35823;",0:exit sub
		for i=0 to ubound(t2)
			if eycms.isnum(t2(i)) then
				eycms.db.dbupdate "ey_attr_set","id="&t3(i)&"",array(array("ordnum",t2(i),10,0,0))
			end if
		next
		eycms.ajaxjson "保存成功",1
	end Sub
	
	sub attrdeldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		dim data:data=eycms.db.dbload(1,"classid,fname","ey_attr_set","id="&id&"","")
		if ubound(data)<0 then
			exit sub
		end If
		eycms.db.dbdel "ey_attr_set","id="&id
		eycms.echo "1"
	end sub
	
	sub attrdelcache()
		eycms.delcache "attr_set"&classid
	end Sub
	
	function get_type(byval t0)
		select case t0
			case "3":get_type="下拉列表"
			case "4":get_type="单选按钮"
		end select
	end function
	
	islogin
	checkpagelever 19
	dim act:act=lcase(eycms.fget("act",0))
	dim data, parentid, classid
	dim user_lock:user_lock=eycms.db.dbloadone("islock","ey_admin_menu","title='会员'")
	select case act
		case "add","addlink","addpage","add_more","addpage_more"
			dim get_category,cid,get_tree,ji
			cid=eycms.getint(eycms.fget("id",0),0)
			data=eycms.categorydata
			if isarray(data) then
				if ubound(data)>=0 then
					for ji=0 to ubound(data,2)
						get_tree=get_tree&""&eycms.iif(ji=0,"",",")&"{"
						get_tree=get_tree&"id:"&data(0,ji)&""
						get_tree=get_tree&",pId:"&data(3,ji)&""
						get_tree=get_tree&",name:"""&data(1,ji)&""""
						get_tree=get_tree&"}"
					next
				end if
			end if
			dim moid:moid=eycms.getint(eycms.fget("moid",0),0)
			dim pname,pnum,cate_list,cate_show
			pname="作为一级栏目"
			pnum=20
			if cid>0 then
				data=eycms.db.dbload("","catename,pagenum,cate_list,cate_show","view_category","cateid="&cid&"","")
				if ubound(data)>=0 then
					pname=data(0,0)
					pnum=data(1,0)
					cate_list=data(2,0)
					cate_show=data(3,0)
				end if
			end if
			load eval("theme_class"&act)
		case "adddb":adddb:recache
		case "addmoredb":addmoredb:recache
		case "addlinkdb":addlinkdb:recache
		case "addpagedb":addpagedb:recache
		case "addpagemoredb":addpagemoredb:recache
		case "edit","editlink","editpage"
			dim iscut,cutw,cuth,id
			iscut=0
			id=eycms.getint(eycms.fget("id",0),0)
			parentid=eycms.get_followid(id)
			data=eycms.db.dbload("","cateid,catename,catedir,modeid,ismenu,catepic,pagenum,ordnum,cate_list,cate_show,seotitle,catekey,catedesc,cateurl,sonid,urlrule,allowpost,model_allowpost,depth,islocked,iscut,cutsize,parentid","view_category","cateid="&id&"","")
			dim rootid:rootid=split(data(22,0),"]")(0)
			rootid=replace(rootid,"[","")
			rootid=CInt(rootid)
			if data(18,0)=1 then iscut=1
			if eycms.get_modeid(rootid)<>data(3,0) then iscut=1
			if data(3,0)>0 then
				dim catenum
				catenum=eycms.db.dbcount("ey_content","classid in("&data(14,0)&")")
			end If
			If InStr(data(21,0),"*") Then
				cutw=Split(data(21,0),"*")(0)
				cuth=Split(data(21,0),"*")(1)
			End if
			load eval("theme_class"&act)
		case "editdb":editdb:recache
		case "editlinkdb":editlinkdb:recache
		case "editpagedb":editpagedb:recache
		case "move"
			id=eycms.getint(eycms.fget("id",0),0)
			dim fid,fname
			data=eycms.db.dbload("","cateid,catename,followid","ey_category","cateid="&id&"","")
			if ubound(data)>=0 then
				fname=data(1,0)
				fid=data(2,0)
				get_category=""
				data=eycms.categorydata
				if isarray(data) then
					if ubound(data)>=0 then
						get_tree=get_tree&"{id:0,pId:-1,name:""作为一级栏目""}"
						for ji=0 to ubound(data,2)
							get_tree=get_tree&",{"
							get_tree=get_tree&"id:"&data(0,ji)&""
							get_tree=get_tree&",pId:"&eycms.iif(data(3,ji)=0,"-1",data(3,ji))&""
							get_tree=get_tree&",name:"""&data(1,ji)&""""
							if fid=data(0,ji) then
								get_tree=get_tree&",checked:true"
							end if
							if data(0,ji)<>data(5,ji) then
								get_tree=get_tree&",open:true"
							end If
							if data(0,ji)=id then
								get_tree=get_tree&",chkDisabled:true"
							end if
							get_tree=get_tree&"}"
						next
					end if
				end if
			end if
			load eval("theme_class"&act)
		case "movedb":movedb:recache
		case "del":deldb:recache
		case "order":orderdb:recache
		case "temp":gettemp
		case "reset":reset:recache
		case "repair":repair:recache
		case "cache":recache
		case "remode":catemode
		case "loadtemp":loadtemp
		case "pinyin":pinyin
		case "english":english
		case "loadson":loadsondb
		case "attr","attradd"
			classid=eycms.getint(eycms.fget("classid",0),0)
			dim wherestr:wherestr=eycms.getWhere(classid)
			load eval("theme_class"&act)
		case "attredit"
			classid=eycms.getint(eycms.fget("classid",0),0)
			id=eycms.getint(eycms.fget("id",0),0)
			Dim datadb:datadb=eycms.db.dbload("","fname,falias,fclass,fdefault,foptions,ordnum,islock","ey_attr_set","id="&id&"","")
			load eval("theme_class"&act)
		case "attradddb":attradddb:attrdelcache
		case "attreditdb":attreditdb:attrdelcache
		case "attrdel":attrdeldb:attrdelcache
		case "attrorder":attrorderdb:attrdelcache
		case else
			dim modeid
			dim class_list:class_list=""
			dim cateid:cateid=eycms.getint(eycms.fget("cateid",0),0)
			parentid=eycms.get_followid(cateid)
			dim cate_mode:cate_mode=eycms.getsys("catemode")
			If cate_mode=0 Then cateid=0
			data=eycms.categorydata
			if isarray(data) then
				classlist(cateid)
				dim mycate:mycate=eycms.getcate(data,cateid)
				if mycate=-1 then
					modeid=0
				else
					modeid=data(10,mycate)
				end if
			end If
			load theme_classlist
	end select
	eycms.db.dbclose
%>
