<!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<%Head()
	dim admin_flag
	admin_flag=",5,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		Call Ms_error()
	Else
	Dim Body
		if request("action")="add" then
			Call Savemsg()
		Elseif Request("action")="del" Then
			Call Del()
		Elseif Request("action")="delall" Then
			Call Delall()
		Elseif Request("action")="delchk" Then
			Call Delchk()
		Elseif Request("action")="delCl" Then
			Call delCl()	
		Else
			call main()
		end if
%>
<p align=center><%=body%></p></font>
<%
	Footer()
End If
sub main()
%>
<table width="95%" border="0" cellspacing="0" cellpadding="0"  align=center class="tableBorder">
  <tr> 
    <th colspan="2" height=24>留言管理 </th>
  </tr>
  <form action="?action=del" method=post>
    <tr> 
      <td colspan="2" class=ForumrowHighLight> 批量删除某用户留言（主要用于批量删除用户留言）：<br> <input type="text" name="username" size="20"> 
        <input type="submit" name="Submit" value="提 交"> </td>
    </tr>
  </form>
  <form action="?action=delall" method=post>
    <tr> 
      <td colspan="2" class=ForumrowHighLight> 批量删除用户指定日期内留言（默认为删除已读留言）：<br> <select name="delDate" size=1>
          <option value=7>一个星期前</option>
          <option value=30>一个月前</option>
          <option value=60>两个月前</option>
          <option value=180>半年前</option>
          <option value="all">所有信息</option>
        </select> &nbsp;
        <input type="checkbox" name="isread" value="yes">
        包括未读留言信息 
        <input type="submit" name="Submit" value="提 交"> </td>
    </tr>
  </form>
  <form action="?action=delchk" method=post>
    <tr> 
      <td colspan="2" class=ForumrowHighLight> 批量删除含有某关键字留言（注意：本操作将删除所有已读和未读留言信息）：<br>
        关键字：
        <input type="text" name="keyword" size=30>
        &nbsp;在 
        <select name="selaction" size=1>
          <option value=1>标题中</option>
          <option value=2>内容中</option>
        </select> &nbsp;
        <input type="submit" name="Submit" value="提 交"> </td>
    </tr>
	</form>
	<form action="?action=delCl" method=post>
    <tr>
      <td height="35" colspan="2" class=ForumrowHighLight>批量删除类留言（注意：本操作将删除所有已读和未读留言信息）：<br>
        <select name="ClassID" id="ClassID">
          <option value="1">约会留言</option>
          <option value="2">站内留言</option>
          <option value="3">速配留言</option>
          <option value="4">聚会留言</option>
        </select>
        <input type="submit" name="Submit" value="提 交"> </td>
    </tr>
  </form>
</table>
<%
end sub

Sub Del()''删除用户留言
	If Request("username") = "" Then
		Body = Body + "<br>" + "请输入要批量删除的用户名。"
		Exit Sub
	End If
	Sql = "DELETE FROM Ms_Note WHERE Username = '" & Request("username") & "'"
	Conn.Execute(Sql)
	Body = Body + "<br>" + "操作成功！请继续别的操作。"
End Sub

Sub delCl()''删除类别留言
	If Request("Classid") = "" Then
		Body = Body + "<br>" + "请输入要批量删除类别留言。"
		Exit Sub
	End If
	Sql = "DELETE FROM Ms_Note WHERE TypeID = " & Request("Classid") & ""
	Conn.Execute(Sql)
	Body = Body + "<br>" + "操作成功！请继续别的操作。"
End Sub

Sub Delall()''删除指定日期留言
	Dim Selflag, Summid
	If Request("isread") = "yes" Then
		Selflag = " ORDER BY NID"
	Else
		Selflag = " AND Flag = 1 ORDER BY NID"
	End If
	Select Case Request("delDate")
	Case "all"
		Sql = "SELECT NID FROM Ms_Note WHERE NID > 0 " & Selflag
	Case 7
		If IsSqlDataBase = 1 Then
			Sql = "SELECT NID From Ms_Note WHERE DATEDIFF(d, Addtime, " & SqlNowString & ") > 7 " & Selflag
		Else
			Sql = "SELECT NID FROM Ms_Note WHERE DATEDIFF('d', Addtime, " & SqlNowString & ") > 7 " & Selflag
		End If
	Case 30
		If IsSqlDataBase = 1 Then
			Sql = "SELECT NID From Ms_Note WHERE DATEDIFF(d, Addtime, " & SqlNowString & ") > 30 " & Selflag
		Else
			Sql = "SELECT NID FROM Ms_Note WHERE DATEDIFF('d', Addtime, " & SqlNowString & ") > 30 " & Selflag
		End If
	Case 60
		If IsSqlDataBase = 1 Then
			Sql = "SELECT NID From Ms_Note WHERE DATEDIFF(d, Addtime, " & SqlNowString & ") > 60 " & Selflag
		Else
			Sql = "SELECT NID FROM Ms_Note WHERE DATEDIFF('d', Addtime, " & SqlNowString & ") > 60 " & Selflag
		End If
	Case 180
		If IsSqlDataBase = 1 Then
			Sql = "SELECT NID From Ms_Note WHERE DATEDIFF(d, Addtime, " & SqlNowString & ") > 180 " & Selflag
		Else
			Sql = "SELECT NID FROM Ms_Note WHERE DATEDIFF('d', Addtime, " & SqlNowString & ") > 180 " & Selflag
		End If
	End Select
	Set Rs = Conn.Execute(Sql)
	Summid = 0
	If Not (Rs.Eof And Rs.Bof) Then
		Sql = Rs.GetRows(-1)
		Rs.Close:Set Rs = Nothing
		For i = 0 To Ubound(Sql,2)
			Conn.Execute("DELETE FROM Ms_Note Where NID = " & Sql(0,i))
			Summid = Summid + 1
		Next
	End If
	Body = Body + "<br>" + "操作删除" & Summid & "条留言成功！请继续别的操作。"
End Sub

sub delchk()''删除指定关键字
	if request.form("keyword")="" then
	body="请输入关键字！"
	exit sub
	end if
	if request.form("selaction")=1 then
	Conn.Execute("delete from Ms_Note where title like '%"&replace(request.form("keyword"),"'","")&"%'")
	body="操作成功！请继续别的操作。"
	elseif request.form("selaction")=2 then
	Conn.Execute("delete from Ms_Note where content like '%"&replace(request.form("keyword"),"'","")&"%'")
	body="操作成功！请继续别的操作。"
	else
	body="未指定相关参数！"
	exit sub
	end if
End Sub%>