<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_lockip.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">问吧IP访问限制管理</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 savelockip()
	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,m_strLockIPlist
	Set Rs = NewAsp.Ask_Execute("SELECT id,LockIPlist FROM NC_Ask_Setup")
	If Rs.BOF And Rs.EOF Then
		Set Rs = Nothing
		FoundErr = True
		ErrMsg = "系统安装错误,找不到系统设置!"
		Exit Sub
	End If
	m_strLockIPlist = TrimLockIPList(Rs("LockIPlist"),1)

%>
<form name="myform" method="post" action="?action=save">
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th colspan="2">IP地址访问限制列表－－管理</th>
</tr>
<tr>
	<td colspan="2" class="tablerow1"><b>说明：</b><br/>您可以添加多个限制IP，每个IP用回车分隔，如：218.28.86.97或218.28.*.*；*.*.*.*将限制所有IP的访问。</td>
</tr>
<tr>
	<td class="tablerow2" width="20%" align="right"><u>IP地址访问限制列表</u>：</td>
	<td class="tablerow2" width="80%"><textarea name="LockIPlist" rows="15" cols="70"><%=m_strLockIPlist%></textarea>
	<div align="left"><a href="javascript:admin_Size(-15,'LockIPlist')"><img src="../images/minus.gif" unselectable="on" border="0"></a>
	<a href="javascript:admin_Size(15,'LockIPlist')"><img src="../images/plus.gif" unselectable="on" border="0"></div>
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right">&nbsp;</td>
	<td class="tablerow1"><input type="submit" value="保存设置" name="submit_button" id="submit_button" class="button"></td>
</tr>
</table>
</form>
<%
End Sub

Sub savelockip()
	Dim Rs,SQL
	Dim m_strLockIPlist
	m_strLockIPlist = TrimLockIPList(Request.Form("LockIPlist"),0)
	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("LockIPlist") = m_strLockIPlist
	Rs.Update
	Rs.Close:Set Rs = Nothing
	NewAsp.DelCache("setup")
	Succeed("<li>恭喜您！保存IP地址访问限制列表完成。</li>")
End Sub

Function TrimLockIPList(str,stype)
	str = Trim(str)
	If IsNull(str) Or Len(str) < 2 Then
		TrimLockIPList = ""
		Exit Function
	End If
	str = Replace(str, vbNewline, "|")
	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
		TrimLockIPList = Replace(s, "|", vbNewline)
	Else
		TrimLockIPList = s
	End If
End Function
%>