<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_badword.asp
' 更新日期：2008-05-16
' 官方网站：新云网络(www.newasp.net www.newasp.cn) QQ：94022511
'=====================================================================
' Copyright 2003-2008 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="200" align="left">问吧字符过滤管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_index.asp">管理首页</a>
			 - <a href="admin_setting.asp?ChannelID=<%=ChannelID%>">问吧设置</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>">问答列表</a>
			 - <a href="admin_lockip.asp?ChannelID=<%=ChannelID%>">IP限制管理</a>
			 - <a href="admin_badword.asp?ChannelID=<%=ChannelID%>">过滤字符管理</a>
		</td>
	</tr>
</table>
<%
Dim Action
Action = LCase(Request("action"))
Select Case Trim(Action)
	Case "save"
		Call saveBadwords()
	Case Else
		Call showmain()
End Select
If FoundErr = True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd

Sub showmain()
	Dim Rs,i,Badwords,m_strBadwords,m_strAuditWord
	Set Rs = NewAsp.Ask_Execute("SELECT id,Badwords FROM NC_Ask_Setup")
	If Rs.BOF And Rs.EOF Then
		Set Rs = Nothing
		FoundErr = True
		ErrMsg = "系统安装错误,找不到系统设置!"
		Exit Sub
	End If
	Badwords = Split(Rs("Badwords")&"$$$","$$$")
	m_strBadwords = TrimBadwords(Badwords(0),1)
	m_strAuditWord = Badwords(1)
	Badwords = Null
%>
<form name="myform" method="post" action="?action=save">
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th colspan="2">过滤字符列表－－管理</th>
</tr>
<tr>
	<td class="tablerow2" width="20%" align="right"><u>过滤字符列表</u>：</td>
	<td class="tablerow2" width="80%"><textarea name="Badwords" rows="20" cols="70"><%=m_strBadwords%></textarea></td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>审核字符列表</u>：<br/>多个字符请用“|”分开</td>
	<td class="tablerow1"><textarea name="AuditWord" rows="15" cols="70"><%=Server.HTMLEncode(m_strAuditWord)%></textarea></td>
</tr>
<tr>
	<td class="tablerow2" align="right">&nbsp;</td>
	<td class="tablerow2"><input type="submit" value="保存设置" name="submit_button" id="submit_button" class="button"></td>
</tr>
<tr>
	<td colspan="2" class="tablerow1"><b>说明：</b><br/>过滤字符设定规则为 <b>要过滤的字符=过滤后的字符</b>（如：新云网络=****） ，每个过滤字符用回车分割开。<br/>
	审核字符主要用于内容中所包含的字符将被禁止提交，需要管理员审核。
	</td>
</tr>
</table>
</form>
<%
End Sub

Sub saveBadwords()
	Dim Rs,SQL
	Dim m_strBadwords,m_strAuditWord
	m_strBadwords = TrimBadwords(Replace(Request.Form("Badwords"), "$$$", ""),0)
	m_strAuditWord = Trim(Replace(Request.Form("AuditWord"), "$$$", ""))
	If FoundErr = True Then Exit Sub
	Set Rs = NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Ask_Setup"
	Rs.Open SQL,Ask_Conn,1,3
		Rs("Badwords") = m_strBadwords & "$$$" & m_strAuditWord
	Rs.Update
	Rs.Close:Set Rs = Nothing
	NewAsp.DelCache("setup")
	Succeed("<li>恭喜您！保存过滤字符列表完成。</li>")
End Sub

Function TrimBadwords(str,stype)
	str = Trim(str)
	If IsNull(str) Or Len(str) < 2 Then
		TrimBadwords = ""
		Exit Function
	End If
	str = Replace(str, vbCrLf, "|")
	str = Replace(str, Chr(13), "")
	str = Replace(str, Chr(10), "|")
	Dim a,s,i
	a = Split(str, "|")
	For i = 0 To UBound(a)
		If Len(a(i)) > 0 Then
			s = s & a(i) & "|"
		End If
	Next
	If Len(s)>0 Then s = Left(s,Len(s)-1)
	If stype = 1 Then
		TrimBadwords = Replace(s, "|", vbCrLf)
	Else
		TrimBadwords = s
	End If
End Function
%>