<%Option Explicit%>
<!--#include file="post.asp"-->
<%dim action,doid,IsEdit
IsErr=False
IsEdit=False
action=request.querystring("action")
doid=request.querystring("id")
If doid="" or (Not Isnumeric(doid)) then
		IsErr=True
		WhatErr="<LI>留言ID参数无效，请从合法链接进入！</LI>"
Else
		doid=Cint(doid)
		SqlData="select top 1 SubMainNumber,name,sex,email,homeurl,face,SubMain,ly from Data where id=" & doid
		Rs.open SqlData,conn,1,1
		if Rs.eof and Rs.bof then
			IsErr=true
			WhatErr="<LI>留言不存在或已经被删除；</LI>"	
		else
			Dim SubMainId,name,sex,email,homeurl,face,SubMain,ly
			SubMainId=Rs(0)
			name=Rs(1)
			sex=Rs(2)
			email=Rs(3)
			homeurl=Rs(4)
			face=Rs(5)
			SubMain=Rs(6)
			ly=Rs(7)
		end if
Rs.close
Set Rs=nothing
End If
if IsErr then 
	DoWhat="操作留言时出错"
else
	select case action
	case "del"
	if session("admin") then
		call del()
		DoWhat="删除留言操作成功"
	else
		call adminerr()
	end if
	case "flower"
		call flower()
		DoWhat="您为该作者送上了一朵鲜花"
	case "egg"
		call egg()
		DoWhat="您为该作者扔去了一个鸡蛋"
	case "edit"
		if session("admin") then
				IsEdit=True
				DoWhat="编辑留言"
				session("BackUrl")=ToUrl
		else
				call adminerr()
		end if
	case "istop"
		if session("admin") then
			call istop()
			DoWhat="主题置顶成功"
		else
			call adminerr()
		end if
	case "isbottom"
		if session("admin") then
			call isbottom()
			DoWhat="主题解除置顶成功"
		else
			call adminerr()
		end if
	case else
			DoWhat="操作留言时出错"
			WhatErr="<LI>操作命令参数无效，请从合法链接进入！</LI>"
	end select
end if

sub del()
    Conn.execute("delete from Data where id=" & doid)
		if SubMainId=0 then	ToUrl="default.asp" else Conn.execute("update Data set report=report-1 where id=" & SubMainId)
end sub

sub flower()	'送花
		Conn.execute("update Data set flower=flower+1 where id=" & doid)
end sub

sub egg()	'扔鸡蛋
		Conn.execute("update Data set egg=egg+1 where id=" & doid)
end sub

sub istop()	'置顶
		Conn.execute("update Data set istop=1 where id=" & doid)
end sub

sub isbottom()	'解除置顶
		Conn.execute("update Data set istop=0 where id=" & doid)
end sub

sub adminerr()	'无权限
DoWhat="操作留言时出错"
WhatErr="<LI>您不是管理员或还没有登陆，请先<a href=""admin.asp"">登陆！</a></LI>"
end sub

sub edit()
SavePostContent=ly
SavePostSubMain=SubMain
SavePostName=name
SavePostEmail=email
SavePostHomeurl=homeurl
SavePostSex=sex
Check(face)="CHECKED"
SaveAction="saveedit&id=" & doid
call PostMainBody()	'调用发帖过程
end sub

call HeadHtml()		'网页头过程
If IsEdit then call edit() else call FounderErr() 		'调用主体过程或信息过程
call FootHtml()		'网页尾过程
Conn.close
Set Conn=nothing
%>