<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/Function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
<script language="javascript">
function CheckAll()
{
var length = document.formed.checkbox.length;
var tocheck = document.formed.SelectAll.checked;

  if (length>=2)
  {
    for (var i=0; i<length; i++){document.formed.checkbox[i].checked = tocheck;}
   }
  else
  {
    document.formed.checkbox.checked = tocheck;    
  }
   
}
</script>
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(5)
Dim act
act=Trim(Request.QueryString("act"))
opendb
Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
Select Case act
	Case "del"
	  Call del()
	Case "show"
	  Call show()
	Case else
	   Call Main()
End Select
Set AskD = Nothing
closedb

Sub Del()
   Dim checkbox
   checkbox=Trim(Request.Form("checkbox"))
   IF checkbox<>"" Then
      Conn.execute("Delete From "&predb&"report where id in("&checkbox&")")
	  Call SendMsg("删除举报成功！")
      Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
   Else
      Response.Write("<script>location.href='?'</script>")
   End IF
End Sub

Sub Show()
Dim ID,rs,rs1,askid
ID=Trim(Request.QueryString("id"))
Set rs=conn.execute("Select ToID,QorA from "&predb&"Report Where ID="&id)
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" align="left">用户举报管理</th>
  </tr>
 <tr>
    <td class="TableRow1"><% If rs("QorA")=1 Then %><img alt="举报的提问" src="Images/r_Ask.gif" border="0" align="absmiddle"><% Else %><img src="Images/r_Ans.gif" alt="举报的回答" border="0" align="absmiddle"><% End If %> <font color="#008800">这是一个针对 <b><% If rs("QorA")=1 Then %>提问<% Else %>回答<% End If %></b> 的举报</font></td>
  </tr>
  <tr>
    <td class="TableRow2">
    <b>被举报的详细内容：</b>
	<%
	IF rs("QorA")=1 Then
	   set rs1=conn.execute("select content from "&predb&"ask where askid="&rs("toid"))
	       Response.Write(rs1("content"))
		   askid=rs("toid")
	   set rs1=nothing
	Else
	   set rs1=conn.execute("select askid,anscontent from "&predb&"ans where ansid="&rs("toid"))
	       Response.Write(rs1("anscontent"))
		   askid=rs1("askid")
	   set rs1=nothing
	End IF
	%>
    </td>
  </tr>
  <tr>
     <td class="TableRow1">
       <input type="button" name="button" id="button" value="返回管理" onClick="location.href='?'">  
     &nbsp; <input type="button" name="button" id="button" value="查看具体" onClick="window.open('../ask.asp?id=<%= askid %>')"></td>
  </tr>
</table>
<%
set rs=nothing
End Sub

Sub Main()
dim rs,i,rs1,sql,c
Dim idcount,maxperpage,n,page,minid
maxperpage=25
page=clng(Request.QueryString("page"))
        set rs=conn.execute("select count(id) from "&predb&"Report")
		idcount=rs(0) 
		set rs=nothing
		
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
IF page>n then page=n
IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Report order by id desc")
		else
		'Response.Write(page&"select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"Report order by id desc) d")
			set rs1=conn.execute("select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"Report order by id desc) d")
			    minid=rs1(0)
			set rs1=nothing
			set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Report where id<"&minid&" order by id desc")
		end if
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="7" align="left">用户举报管理</th>
  </tr>
	<tr>
		<td class="BodyTitle" height="23" align="left" colspan="7"></td>
	</tr>
  <tr>
    <td colspan="7" class="TableRow2"><font color="red"><strong>说明</strong>：设置用户推荐的目的是为了了解网友的关注，为管理员奖惩用户提供参考。</font></td>
  </tr>
  <form method="post" action="?act=del" name="formed" onSubmit="return confirm('请确认您的操作？');">
  <input name="tid" type="hidden" value="1">
 <tr>
    <td width="5%" align="center" class="TableRow1"><strong>选择</strong></td>
    <td width="12%" align="center" class="TableRow1"><strong>被举报者</strong></td>
    <td width="12%" align="center" class="TableRow1"><strong>举报者</strong></td>
    <td width="15%" align="center" class="TableRow1"><strong>举报类型</strong></td>
    <td width="5%" align="center" class="TableRow1"><strong>查看</strong></td>
    <td align="center" class="TableRow1"><strong>举报说明</strong></td>
    <td width="15%" align="center" class="TableRow1"><strong>举报时间</strong></td>
  </tr>
  <%
  do while not rs.eof
i=i+1
if i mod 2=0 then
  c=1
else
  c=2
end if
  %>
  <tr>
    <td align="center" class="TableRow<%= c %>"><input name="checkbox" type="checkbox" value="<%= rs("id") %>"></td>
    <td class="TableRow<%= c %>">
    <%
	set rs1=conn.execute("select userid from "&predb&"user where id="&rs("ToUser"))
	IF rs1.bof and rs1.eof Then
	   Response.Write("<font color=""#999999"">该用户被删除</font>")
    Else
	   Response.Write("<a href=""admin_user.asp?act=change&id="&rs("ToUser")&""">"&rs1("userid")&"</a>")
	End IF 
	set rs1=nothing
	%> 
    </td>
    <td class="TableRow<%= c %>">
    <%
	set rs1=conn.execute("select userid from "&predb&"user where id="&rs("reUser"))
	IF rs1.bof and rs1.eof Then
	   Response.Write("<font color=""#999999"">该用户被删除</font>")
    Else
	   Response.Write("<a href=""admin_user.asp?act=change&id="&rs("reUser")&""">"&rs1("userid")&"</a>")
	End IF 
	set rs1=nothing
	%> 
    </td>
    <td class="TableRow<%= c %>">
    <%
	set rs1=conn.execute("select Incentive from "&predb&"Incentive where id="&rs("retype"))
	IF rs1.bof and rs1.eof Then
	   Response.Write("<font color=""#999999"">该类型已删除</font>")
    Else
	   Response.Write(AskD.LeftStr(rs1("Incentive"),16))
	End IF 
	set rs1=nothing
	%> 
    </td>
    <td align="center" class="TableRow<%= c %>"><a href="?act=show&id=<%= rs("id") %>"><% If rs("QorA")=1 Then %><img alt="举报的提问" src="Images/r_Ask.gif" border="0"><% Else %><img src="Images/r_Ans.gif" alt="举报的回答" border="0"><% End If %></a></td>
    <td class="TableRow<%= c %>"><%= rs("report") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("ReTime") %></td>
  </tr>
  <% 
  rs.movenext
  loop
  %>
  <tr>
    <td colspan="9" align="center" class="TableRow1">共<b><%= idcount %></b>则 <font color="#FF0000"><%= page %></font>/<%= n %>页&nbsp;&nbsp; <a href="?page=1">首页</a>&nbsp;&nbsp; <a href="?page=<%= page-1 %>">上一页</a>&nbsp;&nbsp; <a href="?page=<%= page+1 %>">下一页</a>&nbsp;&nbsp; <a href="?page=<%= n %>">尾页</a></td>
  </tr>
  <tr>
    <td colspan="7" class="TableRow1">
    <label><input type="checkbox" name="SelectAll" id="SelectAll" onClick="CheckAll()">全选\全不选</label>
    &nbsp; <input type="submit" name="button" id="button" value="删除选中的举报"></td>
  </tr>
  </form>
</table>
<%
set rs=nothing
End Sub
%>
<br>
</body>
</html>
