<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/editor/class_fckeditor.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(25)
Dim act
act=Trim(Request.QueryString("act"))
opendb
Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
Select Case act
	Case "add","modi"
	  Call Add()
	Case "save"
	  Call saves()
	Case "del"
	  Call del()
	Case else
	   Call Main()
End Select
set AskD.myConn =Nothing
Closedb
Set AskD = Nothing

Sub DEL()
   dim id
   id=Trim(Request.QueryString("id"))
   IF ID="" Then ID=Trim(Request.Form("checkbox"))
   if ID<>"" then
      conn.execute("delete from "&predb&"Allow where id in("&id&")")
      
	  Call SendMsg("过滤删除成功")
	  Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
   else
	  Response.Write("<script>location.href='?'</script>")
   end if
	  
End Sub

Sub Main()
dim rs,i,c,rs1,sql,j,recU,str

Dim idcount,maxperpage,n,page,minid
maxperpage=25
page=clng(Request.QueryString("page"))
        set rs=conn.execute("select count(id) from "&predb&"Allow")
		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&"Allow order by id desc")
		else
			set rs1=conn.execute("select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"Allow order by id desc) d")
			    minid=rs1(0)
			set rs1=nothing
			set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Allow 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="6" align="left">过滤项目管理</th>
  </tr>
  <form method="post" action="?act=del" name="formed" onSubmit="return confirm('请确认您的操作？');">
  
  <tr>
    <td width="6%" align="center" class="TableRow1"><strong>选择</strong></td>
    <td width="34%" align="center" class="TableRow1"><strong>过滤内容</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>过滤对象</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>过滤方式</strong></td>
    <td align="center" class="TableRow1"><strong>替换内容</strong></td>
    <td width="14%" 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 %>"><%= rs("FiStr") %></td>
    <td align="center" class="TableRow<%= c %>">
	<%
	Select Case rs("Fpos")
	  Case 1
	     Response.Write("提问标题")
	  Case 2
	     Response.Write("提问内容")
      Case 3
	     Response.Write("回答内容")
      Case 4 
	     Response.Write("评论内容")
      Case 5
	     Response.Write("所有对象")
	End Select
	%>    </td>
    <td align="center" class="TableRow<%= c %>">
	<%
	IF rs("Ftype")=1 Then Response.Write("替换") Else Response.Write("禁止")
	%>    </td>
    <td class="TableRow<%= c %>"><%= rs("FeStr") %></td>
    <td align="center" class="TableRow<%= c %>"><a href="?act=modi&id=<%= rs("id") %>">修改</a>&nbsp;&nbsp; <a href="?act=del&id=<%= rs("id") %>" onClick="return confirm('请确认您的操作？');">删除</a></td>
  </tr>
  <% 
  rs.movenext
  loop
  %>
  <tr>
    <td colspan="8" 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="6" class="TableRow1"><label><input type="checkbox" name="SelectAll" id="SelectAll" onClick="CheckAll()">全选\全不选</label>
    &nbsp; <input type="submit" name="button" id="button" value="删除选中">
    &nbsp;
      <input name="b" type="button" id="b" onClick="location.href='?act=add'" value="添加过滤项目">      </td>
  </tr>
  </form>
</table>
<%
set rs=nothing
End Sub

Sub Saves()
	Dim rs,Fpos,Ftype,FiStr,FeStr,id
	id=Trim(Request.Form("id"))
	Fpos=Trim(Request.Form("Fpos"))
	Ftype=Trim(Request.Form("Ftype"))
	FiStr=Trim(Request.Form("FiStr"))
	FeStr=Trim(Request.Form("FeStr"))
	IF FiStr="" Then
	   Call SendMsg("替换内容不可为空！")
	   Response.Write("<script>setTimeout(""history.go(-1)"",800)</script>")
	   Response.End()
	End IF
    IF id="" Then
	Conn.execute("insert into "&predb&"Allow(Fpos,Ftype,FiStr,FeStr) values("&Fpos&","&Ftype&",'"&FiStr&"','"&FeStr&"')")
	
	Call SendMsg("过滤项目添加成功！")
	Else
	Conn.execute("update "&predb&"Allow set Fpos="&Fpos&",Ftype="&Ftype&",FiStr='"&FiStr&"',FeStr='"&FeStr&"' where id="&id)
	
	Call SendMsg("过滤项目修改成功！")
    End IF
	Call AskD.DoAllowXml()
	Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub Add()
dim id,rs,Fpos,Ftype,FiStr,FeStr
id=Trim(Request.QueryString("id"))
IF id<>"" Then
  set rs=conn.execute("select * from "&predb&"Allow where id="&id)
    Fpos=rs("Fpos")
	Ftype=rs("Ftype")
	FiStr=rs("FiStr")
	FeStr=rs("FeStr")
  set rs=nothing
End IF
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="2" align="left">添加过滤项目</th>
  </tr>
  <form method="post" action="?act=save" name="formed">
  <input name="id" type="hidden" value="<%=id%>">
  <tr>
    <td width="21%" align="right" class="TableRow1">过滤对象：</td>
    <td width="79%" class="TableRow1"><select name="Fpos" id="Fpos">
      <option value="1" <% If Fpos=1 Then %>selected<% End If %>>提问标题</option>
      <option value="2" <% If Fpos=2 Then %>selected<% End If %>>提问内容</option>
      <option value="3" <% If Fpos=3 Then %>selected<% End If %>>回答内容</option>
      <option value="4" <% If Fpos=4 Then %>selected<% End If %>>评论内容</option>
      <option value="5" <% If Fpos=5 Then %>selected<% End If %>>所有对象</option>
    </select></td>
  </tr>

  <tr>
    <td align="right" class="TableRow1">过滤方式：</td>
    <td class="TableRow1" id="input0">
    <select name="Ftype" id="Ftype">
      <option value="1" <% If Ftype=1 Then %>selected<% End If %>>替换</option>
      <option value="2" <% If Ftype=2 Then %>selected<% End If %>>禁止</option>
        </select></td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">过滤内容：</td>
    <td class="TableRow2"><input name="FiStr" type="text" id="FiStr" size="30" maxlength="100" value="<%= FiStr %>">
      *</td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">替换内容：</td>
    <td class="TableRow2"><input name="FeStr" type="text" id="FeStr" size="30" maxlength="100" value="<%= FeStr %>">
      可不填写，即替换为空。</td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">&nbsp;</td>
    <td class="TableRow2"><input type="submit" name="button" id="button" value="<% If id="" Then %>添 加<% Else %>修 改<% End If %>">
      &nbsp; <input type="button" name="button2" id="button2" value="返回管理" onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<%
End Sub
%>
<br>
</body>
</html>
