<!--#include file="base.asp"-->
<%
''' EYCMS 图文消息
''' ==================================================================

	sub remarkdb()
		dim t0:t0=eycms.getint(eycms.fget("t0",0),0)
		dim t1:t1=eycms.enhtml(eycms.fget("t1",0))
		eycms.db.dbupdate "wx_master_class","id="&t0&"",array(array("classname",t1,20,1))
		eycms.echo "1"	
	end sub
	
	sub getoutfile()
		dim t0:t0=eycms.fpost("t0",1)
		eycms.echo eycms.deal_outfile(t0,array(0,7,adminid))
	end sub
	
	sub editdb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.fpost("t3",1)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		if eycms.strlen(t1)=0 then t1=penname
		if eycms.strlen(t0)=0 then eycms.ajaxjson "标题不能为空",0:exit sub
		if eycms.strlen(t2)=0 then eycms.ajaxjson "封面不能为空",0:exit sub
		if eycms.strlen(t3)=0 then eycms.ajaxjson "正文不能为空",0:exit sub
		t7=eycms.getallpic(t3,t2)
		if eycms.strlen(t8)=0 then t8=eycms.cutstr(eycms.dishtml(t3),100,1)
		dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
		dim cid:cid=eycms.getint(eycms.fget("cid",0),0)
		dim data:data=array(array("title",t0,64,1),array("author",t1,8,1),array("pic",t2,255,1),array("intro",t8,0,1),array("content",t3,0,1),array("islock",1,0,0),array("oldurl",t4,255,1),array("cid",t5,10,0),array("tid",t6,10,0),array("piclist",t7,0,1),array("lastupdate",now(),50,1))
		if eycms.db.dbupdate("wx_master","id="&cid&"",data)=1 then
			dim imgArr
			imgArr = t2&","&eycms.getfilelist(t3)
			delall imgArr,cid,7
			eycms.db.dbupdate "wx_master_class","id="&classid&"",array(array("islock",1,10,0))
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub newdb()
		dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
		dim tnum:tnum=eycms.db.dbcount("wx_master","classid="&classid&"")
		if tnum<8 then
			eycms.db.insert "wx_master",array(array("classid",classid,10,0),array("ordnum",tnum+1,0,0),array("createdate",now(),50,1),array("islock",0,0,0),array("cid",0,0,0),array("tid",0,0,0),array("hits",0,0,0),array("comments",0,0,0),array("likenum",0,0,0))
			dim cid:cid=eycms.db.insertid_new("id","wx_master","classid="&classid&"")
			eycms.echo cid&":"&tnum+1
		else
			eycms.echo "0"
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "wx_master","id="&id
		eycms.echo "1"
	end sub
	
	sub delclass()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "wx_master","classid="&id
		eycms.db.dbdel "wx_master_class","id="&id
		eycms.echo "1"
	end sub
	
	sub updb()
		dim cid:cid=eycms.getint(eycms.fget("cid",0),0)
		dim lc:lc=eycms.getint(eycms.fget("lc",0),1)
		dim data:data=eycms.db.dbload(1,"classid,ordnum","wx_master","id="&cid&"","")
		if ubound(data)<0 then
			eycms.echo "参数错误1"
		else
			dim classid,ordnum,f
			classid=data(0,0)
			ordnum=data(1,0)
			if lc=2 then
				f=1
			else
				f=0
			end if
			data=eycms.db.dbload(1,"id,ordnum","wx_master","ordnum<"&ordnum&" and classid="&classid&"","ordnum desc")
			if ubound(data)<0 then
				eycms.echo "参数错误3"
			else
				eycms.db.dbupdate "wx_master","id="&data(0,0)&"",array(array("ordnum",ordnum,10,0))
				eycms.db.dbupdate "wx_master","id="&cid&"",array(array("ordnum",data(1,0),10,0))
				eycms.go "?act=add&classid="&classid&"&cid="&cid&"&f="&f&"&lc="&lc-1&""
			end if
		end if
	end sub
	
	sub downdb()
		dim cid:cid=eycms.getint(eycms.fget("cid",0),0)
		dim lc:lc=eycms.getint(eycms.fget("lc",0),1)
		dim data:data=eycms.db.dbload(1,"classid,ordnum","wx_master","id="&cid&"","")
		if ubound(data)<0 then
			eycms.echo "参数错误1"
		else
			dim classid,ordnum
			classid=data(0,0)
			ordnum=data(1,0)
			data=eycms.db.dbload(1,"id,ordnum","wx_master","ordnum>"&ordnum&" and classid="&classid&"","ordnum")
			if ubound(data)<0 then
				eycms.go "?act=add&classid="&classid&"&cid="&cid&"&f=1&lc=1"
			else
				eycms.db.dbupdate "wx_master","id="&data(0,0)&"",array(array("ordnum",ordnum,10,0))
				eycms.db.dbupdate "wx_master","id="&cid&"",array(array("ordnum",data(1,0),10,0))
				eycms.go "?act=add&classid="&classid&"&cid="&cid&"&f=0&lc="&lc+1&""
			end if
		end if
	end sub
	
	islogin
	checkpagelever 67
	dim act:act=lcase(eycms.fget("act",0))
	select case act
		case "add"
			dim cid:cid=eycms.getint(eycms.fget("cid",0),0)
			dim f:f=eycms.getint(eycms.fget("f",0),1)
			dim lc:lc=eycms.getint(eycms.fget("lc",0),1)
			if lc=1 then
				lc=0
			else
				lc=161+(lc-2)*100
			end if
			dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
			if classid=0 then
				dim dt:dt=eycms.db.dbload(1,"id","wx_master_class","islock=0","")
				if ubound(dt)<0 then
					dim n:n=date()
					eycms.db.insert "wx_master_class",array(array("classname",n,50,1),array("islock",0,0,0))
					classid=eycms.db.dbloadone("id","wx_master_class","classname='"&n&"'")
				else
					classid=dt(0,0)
				end if
			end if
			dim nosave:nosave=eycms.db.dbloadone("islock","wx_master_class","id="&classid&"")
			if eycms.db.dbcount("wx_master","ordnum=1 and classid="&classid&"")=0 then
				eycms.db.insert "wx_master",array(array("classid",classid,10,0),array("createdate",now(),50,1),array("ordnum",1,0,0),array("islock",0,0,0),array("cid",0,0,0),array("tid",0,0,0),array("hits",0,0,0),array("comments",0,0,0),array("likenum",0,0,0))
			end if
			if cid=0 then cid=eycms.db.dbloadone("id","wx_master","ordnum=1 and classid="&classid&"")
			dim rsshow
			set rsshow=eycms.db.exedb("select top 1 * from wx_master where id="&cid&"")
			if rsshow.eof then
				eycms.echo "参数错误":eycms.die
			end if
			load theme_master_add
		case "editdb":editdb
		case "new":newdb
		case "del":deldb
		case "delclass":delclass
		case "remark":remarkdb
		case "up":updb
		case "down":downdb
		case "getoutfile":getoutfile
		case "all":load theme_master_all
		case else:load theme_master
	end select
	eycms.db.dbclose
%>