<!--#include file="base.asp"-->
<%
''' EYCMS 留言
''' ==================================================================

	sub configdb()
		dim t0,t1
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		eycms.db.dbupdate "ey_config","setname='eycms.expand' and setkey='expand.book'",array(array("setvalue","array("""&t0&""","""&t1&""")",0,1))
		eycms.delcache "eycmsdata"
		eycms.ajaxjson "保存成功",1
	end sub
	
	sub editdb()
		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.enhtml(eycms.fpost("t4",0))
		t5=eycms.getint(eycms.fpost("t5",0),0)
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26165;&#31216;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t3)=0 then eycms.ajaxjson "&#35780;&#35770;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		dim data,id
		id=eycms.getint(eycms.fget("id",0),0)
		if eycms.strlen(t4)<>0 then
			data=array(array("username",t0,50,1),array("sex",t1,0,1),array("tel",t2,50,1),array("content",t3,255,1),array("reply",t4,255,1),array("islock",t5,0,0),array("replydate",sqltime,0,0))
		else
			data=array(array("username",t0,50,1),array("sex",t1,0,1),array("tel",t2,50,1),array("content",t3,255,1),array("reply",t4,255,1),array("islock",t5,0,0))
		end if
		if eycms.db.dbupdate("ey_expand_book","id="&id&"",data)=1 then
			eycms.ajaxjson "保存成功",1
		end if
	end sub
	
	sub deldb()
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		eycms.db.dbdel "ey_expand_book","id="&id
		eycms.echo "1"
	end sub
	
	sub doset()
		dim id:id=eycms.enhtml(eycms.fget("id",0))
		dim go:go=eycms.enhtml(eycms.fget("go",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			eycms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					eycms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				end if
			next
			dim filed,result
			select case go
				case "islock":filed="islock":result=0
				case "nolock":filed="islock":result=1
				case else:eycms.echo "0&#21442;&#25968;&#38169;&#35823;":exit sub
			end select
			eycms.db.dbupdate "ey_expand_book","id in("&id&")",array(array(filed,result,2,0))
			eycms.echo "1"
		end if
	end sub
	
	sub delsome()
		dim id:id=eycms.enhtml(eycms.fget("id",0))
		dim idarr:idarr=split(id,",")
		if ubound(idarr)<0 then
			eycms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					eycms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				else
					eycms.db.dbdel "ey_expand_book","id="&idarr(i)
				end if
			next
			eycms.echo "1"
		end if
	end sub
	
	islogin
	checkpagelever 34
	dim act:act=lcase(eycms.fget("act",0))
	dim sqlwhere,nattitle,nat,cid
	nat=eycms.getint(eycms.fget("nat",0),0)
	select case act
		case "config"
			dim sitedata,data
			sitedata=eycms.db.dbload(1,"setvalue","ey_config","setname='eycms.expand' and setkey='expand.book'","")
			data=eval(sitedata(0,0))
			load eval("theme_expand_book_"&act)
		case "configdb":configdb
		case "edit"
			dim datadb,id
			id=eycms.getint(eycms.fget("id",0),0)
			datadb=eycms.db.dbload("","username,sex,tel,content,reply,islock","ey_expand_book","id="&id&"","")
			load eval("theme_expand_book_"&act)
		case "editdb":editdb
		case "del":deldb
		case "doset":doset
		case "delsome":delsome
		case else
			select case nat
				case "1":sqlwhere=" and islock=0":nattitle="性质:未审"
				case "2":sqlwhere=" and islock=1":nattitle="性质:已审"
				case "3":sqlwhere=" and (reply is null or reply='')":nattitle="性质:未回复"
				case "4":sqlwhere=" and not(reply is null or reply='')":nattitle="性质:已回复"
				case else:nattitle="按性质↓"
			end select
			load theme_expand_book
	end select
	eycms.db.dbclose
%>
